home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
bioinformatics.org
/
bioinformatics.org_software.tar
/
www.bioinformatics.org
/
download
/
ecell2
/
ecell220setup.exe
/
{app}
/
standard
/
SRCJ
/
Preference.java
< prev
next >
Wrap
Text File
|
2002-05-13
|
4KB
|
135 lines
/**
* title: Preference class (Preference.java)<p>
* description : Preference window class<p>
* Copyright (C) 1996-2001 Keio University <p>
* Copyright (C) 1998-2001 Japan Science and Technology Corporation (JST)<p>
* GNU General Public Licence <p>
* Division: Mitsui Knowledge Industry Co. Ltd. Bioscience division <p>
* Version : $Id: Preference.java,v 1.7 2002/05/13 00:23:04 ota Exp $ <p>
*/
/**
* title : Preference<p>
* description : Preference Window<p>
* @author Xiangdong Zheng
* @version 1.0
*/
package ecell;
import javax.swing.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.awt.*;
/**
* Preference window class
* @author XD.Zheng
* @version 1.0
* @since JDK1.2.2
*/
public class Preference extends JDialog
{
JPanel jp1 = new JPanel();
JPanel jp2 = new JPanel();
JLabel label1 = new JLabel("Step interval: ");
JLabel label2 = new JLabel("Update interval:");
JTextField text1 = new JTextField(70);
JTextField text2 = new JTextField(70);
JButton buttonOk = new JButton("Ok");
JButton buttonClose = new JButton("CANCEL");
/**
*CtrollorPanel
*/
MainWindow window ;
/**
*Constructor
*@param owner Ctrollor Panel
*/
public Preference(MainWindow owner) {
super((Frame)owner,"Preferences",true);
this.window=owner;
jp1.setLayout(new GridLayout(2,2));
text1.setSize(70,30);
text2.setSize(70,30);
jp1.add(label1);
jp1.add(text1);
jp1.add(label2);
jp1.add(text2);
// 2001.12.25 for ECELL2.2
//text1.setText(""+ window.df.getPreferenceStep());
//text2.setText(""+window.df.getPreferenceUpdate());
text1.setText( "" + window.engine.getPreferenceStep() );
text2.setText( "" + window.engine.getPreferenceUpdate() );
jp2.setLayout(new FlowLayout(0,2,2));
buttonOk.addActionListener(actionListener);
buttonClose.addActionListener(actionListener);
jp2.add(buttonOk);
jp2.add(buttonClose);
this.getContentPane().add(jp1,"Center");
this.getContentPane().add(jp2,"South");
this.addWindowListener(wListener);
this.setLocation(250,200);
}
/**
* Instance of actionListener
*/
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(e.getSource()== buttonOk){
try{
double step = Double.parseDouble(text1.getText().trim());
int update = Integer.parseInt(text2.getText().trim());
// 2001.12.25 for ECELL2.2
//window.df.setPreference(step,update);
window.engine.setPreference( step, update );
Preference.this.setVisible(false);
Preference.this.dispose();
}catch(NumberFormatException ex){
Object message ="No input or input error!!";
String title ="Preference";
int messageType = JOptionPane.ERROR_MESSAGE;
JOptionPane.showMessageDialog(Preference.this,message,
title,messageType);
} catch(Exception ex){
window.messageWindow.setErrorMessage( ex );
}
}
if(e.getSource()== buttonClose){
Preference.this.setVisible(false);
Preference.this.dispose();
}
}
};
/**
* Instance of WindowListener
*/
WindowListener wListener = new WindowListener() {
public void windowOpened(WindowEvent e){}
public void windowClosing(WindowEvent e){
Preference.this.setVisible(false);
Preference.this.dispose();
}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
};
}